library("tidyverse")
library("firatheme")
library("prediction")
library("estimatr")
library("texreg")
library("visreg")

# load data
load("~/df_replication_votes.RData")

model9 <- glm(click ~ cue + issue + votes + region + party_name, data = df_replication_votes, family="binomial")
model10 <- glm(click ~ cue*votes + issue*votes + region + party_name, data = df_replication_votes, family="binomial")

# Figure S 14 - upper panel
visreg(model9, "votes", scale = "response", band = T, rug=2, xlab="personal votes",
       ylab="P(click)",gg=T, fill=list(col="gray80", alpha=0.3),
       line=list(lty=1, col="gray30")) + theme_fira() 

# Figure S 14 - lower panel
visreg(model10, "votes", by="cue", scale = "response", band = T, rug=2, xlab="personal votes",
       ylab="P(click)", gg=T, fill=list(col="gray80", alpha=0.3),
       line=list(lty=1, col="gray30")) + facet_wrap(vars(cue), nrow = 2) + theme_fira() 

